# -*- coding: utf-8 -*-
"""
@Time    : 2021/3/18 9:25
@Author  : hui lin
"""
from typing import Callable, Type, List
from pygame import Surface
from pygame.event import Event


_need_reload = True


class ScreenBase(object):

    def __init__(self, screen: Surface):
        self._screen = screen
        self.is_close: bool = False
        self.wait_events: List[Event] = []
        self.is_changing_scene: bool = False

    def init_screen(self, *args, **kwargs):
        raise NotImplementedError

    async def update(self, events: List[Event] = None, **kwargs):
        raise NotImplementedError


SCREEN_REGISTER_CLASS: dict[str, Callable[[Surface], Type[ScreenBase]]] = {}


def register_screen(screen_name: str):
    """注册screen"""
    def _do_register(cls: Callable[[Surface], Type[ScreenBase]]):
        SCREEN_REGISTER_CLASS[screen_name] = cls
        return cls

    return _do_register
